//token.js是专门用来管理token的文件
let token = {
    set(token) {
        localStorage.setItem("token",token)
    },
    get() {
        return localStorage.getItem("token")
    },
    setUser(user) {
        localStorage.setItem("user",JSON.stringify(user))
    },
    getUser() {
        if(localStorage.getItem("user")) {
            return JSON.parse(localStorage.getItem("user"))
        }
    },
    clear() {
        //清空token
        localStorage.removeItem("token")
        localStorage.removeItem("user")
    }
}

export default token